package com.ruoyi.system.domain.vo;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

/**
 * @author suhuazhao
 * @date 2023-05-28  22:28
 * @description
 * {
 *   name: "MFO",
 *   lastestTime: "2020-10-10 00:01:02",
 *   warning: 10,
 *   critical: 5,
 *   href: "http://baidu.com",
 * },
 */
@Accessors(chain = true)
@Data
public class WarnDigestDTO {
    private Long configId;
    private String configType;
    private String name;
    private Integer sort;
    @JSONField(name = "lastest_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastestTime;
    private Integer warning;
    private Integer critical;
    private Integer normal;
    private String href;

    private List<WarnDigestDetailVo> detailList;

    public WarnDigestDTO setLastestTime(Long lastestTime) {
        if (lastestTime != null) {
            this.lastestTime = new Date(lastestTime * 1000);
        }
        return this;
    }

    public WarnDigestDTO setLastestTime(Date lastestTime) {
        this.lastestTime = lastestTime;
        return this;
    }

    public boolean hasCount() {
        return normal + warning + critical > 0;
    }
}
